﻿@using CNKI.TPI.Web.Search.Model;
@using CNKI.TPI.Web.Admin.Model;
<script>
    //用户组全选
    function groupcheckall(e) {
        if ($(e).attr("checked") == "checked") {
            $(".checkboxgroup input[type='checkbox']").each(function () {
                $(this).attr("checked", "checked");
            })
        }
        else {
            $(".checkboxgroup input[type='checkbox']").each(function () {
                $(this).removeAttr("checked", "checked");
            })
        }
    }
    $(".checkboxgroup input[type='checkbox']").click(function () {
        //循环判断列表中的checkbox，如果全部选中则全选框呈勾选状态
        var m = 0;
        if ($(this).attr("checked") != "checked") {
            $("input.groupall").removeAttr("checked", "checked");
        }
        else {
            dealchecked(".checkboxgroup input[type='checkbox']", "input.groupall");
        }

    })
    //ip全选
    function ipcheckall(e) {
        if ($(e).attr("checked") == "checked") {
            $(".checkboxip input[type='checkbox']").each(function () {
                $(this).attr("checked", "checked");
            })
        }
        else {
            $(".checkboxip input[type='checkbox']").each(function () {
                $(this).removeAttr("checked", "checked");
            })
        }
    }
    $(".checkboxip input[type='checkbox']").click(function () {
        //循环判断列表中的checkbox，如果全部选中则全选框呈勾选状态
        var m = 0;
        if ($(this).attr("checked") != "checked") {
            $("input.ipall").removeAttr("checked", "checked");
        }
        else {
            dealchecked(".checkboxip input[type='checkbox']", "input.ipall");
        }

    })

    //密级全选
    $(".f-checkboxsec").click(function () {
        if ($(this).attr("checked") == "checked") {
            //全选
            $(".f-checkbox").each(function () {
                $(this).attr("checked", "checked");
            })
        }
        else {
            //取消全选
            $(".f-checkbox").each(function () {
                $(this).removeAttr("checked", "checked");
            })
        }

    })
    $(".f-checkbox").click(function () {
        //循环判断列表中的checkbox，如果全部选中则全选框呈勾选状态
        var m = 0;
        if ($(this).attr("checked") != "checked") {
            $(".f-checkboxsec").removeAttr("checked", "checked");
        }
        else {
            dealchecked(".f-checkbox", ".f-checkboxsec");
        }

    })
    //根据不同的密级，置灰不同的选项
    $('input:radio[name="radiosec"]').change(function () {
        radiochange($(this).val())
    })
    function radiochange(value) {
        if (value == 0) {

            $("#securityvalue").attr("disabled", "disabled");
            $(".f-checkbox").attr("disabled", "disabled");
            $(".f-checkboxsec").attr("disabled", "disabled");

        }
        else if (value == 1) {
            $(".f-checkbox").attr("disabled", "disabled");
            $(".f-checkboxsec").attr("disabled", "disabled");

            $("#securityvalue").removeAttr("disabled", "disabled");

        }
        else if (value == 2) {
            $("#securityvalue").attr("disabled", "disabled");
            $(".f-checkbox").removeAttr("disabled", "disabled");
            $(".f-checkboxsec").removeAttr("disabled", "disabled");

        }
    }
    //密级字段，用户组全选
    function dealchecked(checkedsub, checkedparent) {
        var m = 0;
        $(checkedsub).each(function () {
            if ($(this).attr("checked") != "checked") {  //遍历判断是否存在没有选中的记录
                m = 1;
            }
        })
        if (m == 1) {
            $(checkedparent).removeAttr("checked", "checked");
        }
        else {
            $(checkedparent).attr("checked", "checked");
        }
    }
    function addIP() {

        $(".talkDiv-title span").html("添加IP");
        $("#startIP").val("");
        $("#endIP").val("");
        $("#ipSortNo").val(0);//代表新增IP
        $(".talkDivBg").show();
        $(".form-h-8em").show();
    }
    function deleteMult() {
        var ckbs = $(".checkboxip input[type='checkbox']:checked");
        if (ckbs.size() == 0) {
            messageAlert("请选择要删除的记录！");
            return;
        }
        confirmDialog('确定要删除吗?', function () {
            ckbs.each(function () {
                //遍历删除
                $(this).parent().parent().remove();

            })
            //序号重新赋值
            $('#iptable tbody tr').each(function (i) {
                $(this).find("td").eq(0).html("<input type=\"checkbox\" value=" + (i + 1) + " >" + (i + 1))
                var colortype = "even";
                if ((i + 1) % 2 == 0) {
                    colortype = "odd";
                }
                $(this).attr("class", colortype);//隔行变色
            })
            $(".ipall").removeAttr("checked", "checked");
        })


    }
    function closeIP() {
        $(".talkDivBg").hide();
        $(".form-h-8em").hide();
    }
 
    function saveIP() {
        var startip = $("#startIP").val();
        var endip = $("#endIP").val();
        //验证IP
        if (startip != "" && startip.length != 0) {
            if (!validateIP(startip)) {
                messageAlert('您输入起始IP格式不正确!');
                return;
            }
        }
        else {
            messageAlert("请输入起始IP");
            return;
        }
        if (endip != "" && endip.length != 0) {
            if (!validateIP(endip)) {
                messageAlert('您输入终止IP格式不正确!');
                return;
            }
        }
        else {
            messageAlert("请输入终止IP");
            return;
        }
        if ($("#ipSortNo").val() == "0") { //新增
            //往table里面插入一行数据
            var thisindex = $("#iptable").find("tr").length; //序号
            var colortype = "even";
            if (thisindex % 2 == 0) {
                colortype = "odd";
            }
            var str = "<tr class=\"{0}\"><td class=\"checkboxip\"><input type=\"checkbox\" value=\"{1}\">{1}</td><td>{2}</td><td>{3}</td>"
                        + "<td class=\"tc\"><a href=\"javascript:void(0);\" onclick=\"editIP(this)\">编辑 </a>"
                                          + "<a href=\"javascript:void(0);\" onclick=\"deleteIP(this)\">删除</a></td></tr>";
            str = $.format(str, colortype, thisindex, startip, endip);
            $("#iptable").append(str);
        }
        else { //修改

            var a = "";
            $('#iptable tbody tr').each(function () {

                if ($(this).find("td").eq(0).find("input").val() == $("#ipSortNo").val()) {
                    $(this).find("td").eq(1).html(startip);
                    $(this).find("td").eq(2).html(endip);
                }

            })
        }
        closeIP();

    }

    function editIP(obj) {
        var sortno = $(obj).parent().parent().find("td").eq(0).find("input").val();
        var startip = $(obj).parent().parent().find("td").eq(1).html();
        var endip = $(obj).parent().parent().find("td").eq(2).html();
        $(".talkDiv-title span").html("编辑IP");
        $("#startIP").val(startip);
        $("#endIP").val(endip);
        $("#ipSortNo").val(sortno);
        $(".talkDivBg").show();
        $(".form-h-8em").show();
    }
    function deleteIP(obj) {
        confirmDialog('确定要删除吗?', function () {
            $(obj).parents("tr").siblings().each(function (i) {
                $(this).find("td").eq(0).html("<input type=\"checkbox\" value=" + (i + 1) + " >" + (i + 1)) //序号重新赋值
                var colortype = "even";
                if ((i + 1) % 2 == 0) {
                    colortype = "odd";
                }
                $(this).attr("class", colortype);//隔行变色

            })
            $(obj).parents("tr").remove();
        })
    }

    $(function () {
        enablesave();
        unitchange();

        dealchecked(".checkboxgroup input[type='checkbox']", "input.groupall");
        dealchecked(".f-checkbox", ".f-checkboxsec");
        radiochange($('input:radio[name="radiosec"]:checked').val());

        if ($("#thisUserID").val() != 0)//修改
        {
            $("#username").attr("disabled", "disabled");
        }
        else {
            $("#username").removeAttr("disabled", "disabled");
        }
    })
    //单位变化，绑定部门
    function unitchange() {
        var uid = $("#selectunit").val();
        var deptobj = $("#selectdept");
        if (uid == "") {
            deptobj.val("");
            deptobj.empty();
            return;
        }
        
        $.ajax({
            type: "GET",
            url: timestamp("@Html.Raw(Url.Action("GetDeptByUnit", "Admin_User"))?uid=" + uid),
            success: function (obj) {
                deptobj.val("");
                deptobj.empty();
                if (obj != null && obj.length > 0) {
                    var str = "<option value='{0}'{1}>{2}</option>";
                    for (var i = 0; i < obj.length; i++) {
                        if (obj[i].SYSID == $("#deptid").val()) {
                            deptobj.append($.format(str, obj[i].SYSID, "selected=selected", obj[i].DEPTNAME));
                        }
                        else {
                            deptobj.append($.format(str, obj[i].SYSID, "", obj[i].DEPTNAME));
                        }
                    }
                }
            },
            error: function (e)
            { }
        })
    }
    function disablesave() {
        $(".btn-warn-f").attr("disabled", "disabled");
    }
    function enablesave() {
        $(".btn-warn-f").removeAttr("disabled", "disabled");
    }
    function userSave() {
        disablesave();
        //验证用户名是否重复
        var uname = $("#username").val();
        if ($.trim(uname) == "") {
            messageAlert("请输入账号！");
            enablesave();
            return;
        }
        else {
            if (!regusername(uname)) {
                messageAlert("请输入账号(只允许输入字母，数字，下划线)！");
                enablesave();
                return;
            }
        }
        var realname = $("#realyname").val();
        if (realname != "") {
            if (!regtext(realname)) {
                messageAlert("请输入姓名(不能包含特殊字符)！");
                enablesave();
                return;
            }
        }

        var tel = $("#telphone").val();
        if (tel != "" && !regtel(tel)) {
            messageAlert("请输入正确的电话号码！");
            enablesave();
            return;
        }
        var email = $("#email").val();
        if (email != "" && !regemail(email)) {
            messageAlert("请输入正确的E-Mail！");
            enablesave();
            return;
        }
        var psot = $("#postcode").val();
        if (psot != "" && !regpostcode(psot)) {
            messageAlert("请输入正确的邮政编码！");
            enablesave();
            return;
        }
        var address = $("#ipaddress").val();
        if (address != "" && !regtext(address)) {
            messageAlert("请输入地址（不允许包含特殊字符）！");
            enablesave();
            return;
        }

        var m = 0;
        if ($("#thisUserID").val() == 0) {  //新增时判断，修改时不判断
            $.ajax({
                type: "GET",
                async: false,
                url: timestamp("@Html.Raw(Url.Action("IsExitUser", "Admin_User"))?username=" + uname),
                success: function (obj) {
                    if (obj == 1) {
                        messageAlert("该账号已经存在请修改账号！");
                        enablesave();
                        m = 1;
                    }
                },
                error: function (e)
                { }
            })
        }
        if (m == 0) {
            savedata();
        }
    }
    function savedata() {
        //保存用户
        var security = $('input:radio[name="radiosec"]:checked').val();
        var secvalue = "";
        if (security == 1)//密级
        {
            secvalue = $("#securityvalue").val();
            if (secvalue == "") {
                messageAlert("请选择密级！");
                enablesave();
                return;
            }
        }
        else if (security == 2) {
            var jsonfield = [];//
            $(".f-checkbox:checked").each(function () {
                jsonfield.push($(this).val());
            })
            if (jsonfield == "") {
                messageAlert("请勾选密级！");
                enablesave();
                return;
            }
            secvalue = jsonfield.toString();
        }
        var userobj = {
            "SysID": $("#thisUserID").val(),
            "Username": $("#username").val(),
            "RealName": $("#realyname").val(),
            "Password": $("#password").val(),
            "Unit": $("#selectunit").val() == "" ? "" : $("#selectunit").find("option:selected").text(),
            "UnitSysID": $("#selectunit").val(),
            "Dept": $("#selectdept").find("option:selected").text(),
            "DeptSysID": $("#selectdept").val(),
            "TelePhone": $("#telphone").val(),
            "Email": $("#email").val(),
            "PostCode": $("#postcode").val(),
            "Address": $("#ipaddress").val(),
            "BeginDate": $("#startdate").val(),
            "EndDate": $("#enddate").val(),
            "StopFlag": $("#userstop").val(),
            "SecurityType": security,
            "SecurityValue": secvalue
        } //用户

        var jsongroup = [];//用户组
        $(".checkboxgroup input[type='checkbox']:checked").each(function () {
            var dataobj = {
                "GroupID": $(this).val()
            }
            jsongroup.push(dataobj);
        })

        //用户IP
        var jsonip = [];//用户IP
        $('#iptable tbody tr').each(function () {
            var iplist = {
                "SIP": $(this).children().eq(1).text(),
                "EIP": $(this).children().eq(2).text(),
                "Flag": "0"
            }
            jsonip.push(iplist);
        })
        var dataold = { "userobj": userobj, "grouplist": jsongroup, "iplist": jsonip };
        var urlaction = "@Html.Raw(Url.Action("SaveUserInfo", "Admin_User"))";
        $.ajax({
            type: "POST",
            url: urlaction,
            //data: dataold,
            data: JSON.stringify(dataold),
            contentType: "application/json",
            success: function (msg) {
                if (msg == "1") {
                    ajaxLoad("initload", '@Html.Raw(Url.Action("UserIndex", "Admin_User"))');
                }
                else {
                    messageAlert("操作失败！");
                    enablesave();
                }
            },
            error: function (e)
            { }
        })
    }
</script>
<div class="wrapR-c">
    <input hidden="hidden" value="@ViewBag.thisUserID" id="thisUserID" type="hidden" />
    <input hidden="hidden" value="0" id="ipSortNo" type="hidden" />
    <div class="box">
        <h3 class='box-h'>用户信息</h3>
        @{
            SYS_CMS_USER obj = new SYS_CMS_USER();
            if (ViewBag.User != null)
            {
                obj = ViewBag.User;
            }
            <input type="hidden" id="deptid"  value="@obj.UnitSysID" />
            <ul class="box-b form-h form-h-5em clearfix">
                <li>
                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">账号</label>
                        </div>
                        <div class="f-ct f-ml">
                            <input type="text" class="f-text span3" id="username" value="@obj.Username" maxlength="20"><span class="f-label-re">*</span>
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">单位名称</label>
                        </div>
                        <div class="f-ct">
                            <select class="f-select span3" onchange="unitchange()" id="selectunit">
                                @if (ViewBag.User == null) //新增时 该项为选中项
                                {
                                    <option value="" selected="selected">请选择单位</option>
                                }
                                else
                                {
                                    <option value="">请选择单位</option>
                                }
                                @if (ViewBag.UserUnit != null)
                                {
                                    foreach (SYS_CMS_USER_UNIT item in ViewBag.UserUnit)
                                    {
                                        if (obj.UnitSysID == item.SYSID)
                                        {
                                    <option value="@item.SYSID" selected="selected">@item.UNITNAME</option>
                                        }
                                        else
                                        {
                                    <option value="@item.SYSID">@item.UNITNAME</option>
                                        }
                                    }
                                }
                            </select>
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">E-mail</label>
                        </div>
                        <div class="f-ct f-ml">
                            <input type="text" class="f-text span3" id="email" value="@obj.Email" maxlength="120">
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">开户日期</label>
                        </div>
                        <div class="f-ct f-ml">
                            @{
                                string datestart = obj.BeginDate;
                                if (ViewBag.thisUserID == 0)//新增模式
                                {
                                    datestart = System.DateTime.Now.ToString("yyyy-MM-dd");
                                }
                            }
                            <input type="text" class="f-text span3" id="startdate" value="@datestart" readonly="true" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'enddate\')}',dateFmt:'yyyy-MM-dd' })">
                        </div>
                    </div>
                </li>

                <li>
                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">姓名</label>
                        </div>
                        <div class="f-ct f-ml">
                            <input type="text" class="f-text span3" id="realyname" value="@obj.RealName" maxlength="20">
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">部门</label>
                        </div>
                        <div class="f-ct">
                            <select class="f-select span3" id="selectdept">
                            </select>
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">邮编</label>
                        </div>
                        <div class="f-ct f-ml">
                            <input type="text" class="f-text span3" id="postcode" value="@obj.PostCode" maxlength="24">
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">终止日期</label>
                        </div>
                        <div class="f-ct f-ml">
                            @{
                                string dend = obj.EndDate;
                                if (ViewBag.thisUserID == 0)//新增模式
                                {
                                    dend = System.DateTime.Now.AddYears(10).ToString("yyyy-MM-dd");
                                }
                            }
                            <input type="text"  class="f-text span3" id="enddate" value="@dend" readonly="true" onclick="WdatePicker({ minDate: '#F{$dp.$D(\'startdate\')}', dateFmt: 'yyyy-MM-dd' })" />
                            @*<input type="text"  class="f-text span3" id="enddate" value="@obj.EndDate" readonly="true" onclick="WdatePicker({minDate:'#F{$dp.$D(\'startdate\')&&\'%y-%M-{%d+1}\'}'})">*@
                        </div>
                    </div>
                </li>

                <li class='last'>
                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">密码</label>
                        </div>
                        <div class="f-ct f-ml">
                            <input class="f-text span3" type="password" id="password" value="@obj.Password" maxlength="32">
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">电话</label>
                        </div>
                        <div class="f-ct">
                            <input type="text" class="f-text span3" id="telphone" value="@obj.TelePhone" maxlength="120">
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">地址</label>
                        </div>
                        <div class="f-ct f-ml">
                            <input type="text" class="f-text span3" id="ipaddress" value="@obj.Address" maxlength="254">
                        </div>
                    </div>

                    <div class="f-gp">
                        <div class="f-lb">
                            <label class="f-label">用户停用</label>
                        </div>
                        <div class="f-ct">
                            <select class="f-select span3" id="userstop">
                                @if (obj.StopFlag == 1)
                                {
                                    <option value="1" selected="selected">是</option>
                                    <option value="0">否</option>
                                }
                                else
                                {
                                    <option value="1">是</option>
                                    <option value="0" selected="selected">否</option>
                                }
                            </select>
                        </div>
                    </div>
                </li>
            </ul>
        }
    </div>
    <div class="box">
        <h3 class='box-h box-h-noborder'>用户组设置</h3>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="table table-grey" id="ipgroup">
            <thead class='th-wr'>
                <tr class="thead">
                    <th class="tdnum tdnum1">
                        <input type="checkbox" class="groupall" onclick="groupcheckall(this)">序号</th>
                    <th class='tc'>组名</th>
                    <th>组描述</th>
                </tr>
            </thead>
            <tbody>

                @{if (ViewBag.UserGroup != null)
                  {
                      int sortno = 1;
                      foreach (SYS_CMS_GROUP item in ViewBag.UserGroup)
                      {
                          string str = "even";
                          if (sortno % 2 == 0)
                          {
                              str = "odd";
                          }
                       
                    <tr class='@str'>
                        <td class="checkboxgroup">
                            @if (ViewBag.thisUserID != 0)//修改模式
                            {
                                if (ViewBag.UserGroupID != null)
                                {
                                    string grupstr = "," + ViewBag.UserGroupID + ","; //加逗号，避免2个ID之间存在包含关系（1，19，199）
                                    if (grupstr.Contains("," + item.SysID.ToString() + ","))
                                    {
                                <input type="checkbox" value="@item.SysID" checked="checked" >@sortno
                                    }
                                    else
                                    {
                                <input type="checkbox" value="@item.SysID" >@sortno
                                    }

                                }
                                else
                                {
                                <input type="checkbox" value="@item.SysID" >@sortno
                                }
                            }
                            else  //新增模式
                            {
                                if (item.Name.ToUpper() == "USERS")
                                {
                                <input type="checkbox" value="@item.SysID" checked="checked" >@sortno
                                }
                                else
                                {  <input type="checkbox" value="@item.SysID" >@sortno
                                }

                            }
                        </td>
                        <td style="width: 150px">@item.Name</td>
                        <td>@item.Descript</td>
                    </tr>
                            sortno = sortno + 1;
                      }
                  }

                }

            </tbody>
        </table>
    </div>

    <div class="box">
        <h3 class='box-h'>用户密级设置</h3>
        <div class="box-b form-wr f14">

            <div>
                <label class="f-label">
                    @if (obj.SecurityType == 0)
                    {
                        <input type="radio" value="0" class="f-radio" name="radiosec" checked="checked">
                    }
                    else
                    { 
                        <input type="radio" value="0" class="f-radio" name="radiosec">
                    }
                    无密级</label>
            </div>

            <div>
                <label class="f-label">
                    @if (obj.SecurityType == 1)
                    {
                        <input type="radio" value="1" class="f-radio" name="radiosec" checked="checked">
                    }
                    else
                    {  
                        <input type="radio" value="1" class="f-radio" name="radiosec">
                    }
                    密级从低到高划分，高密级能够查看低密级的记录</label>
                <select class="f-select span2" id="securityvalue">
                    @if (ViewBag.User == null) //新增时 该项为选中项
                    {
                        <option value="" selected="selected">请选择密级</option>
                    }
                    else
                    {
                        <option value="">请选择密级</option>
                    }

                    @if (ViewBag.Security != null)
                    {
                        foreach (SYS_CMS_SECURITY item in ViewBag.Security)
                        {
                            if (obj.SecurityType == 1 && obj.SecurityValue == item.Value)
                            {
                        <option value="@item.Value" selected="selected">@item.Name</option>
                            }
                            else
                            {
                        <option value="@item.Value">@item.Name</option>
                            }
                        }
                    }
                </select>
            </div>

            <div>
                <label class="f-label">
                    @if (obj.SecurityType == 2)
                    {
                        <input type="radio" value="2" class="f-radio" name="radiosec" checked="checked">
                    }
                    else
                    {
                        <input type="radio" value="2" class="f-radio" name="radiosec">
                    }
                    密级不分等级，密级可以多选并只能查看所选密级记录</label>


                <div class="box-b form-wr">

                    <label class="f-label block">
                        <input type="checkbox" class="f-checkboxsec">全选</label>

                    <div class='clearfix'>
                        @if (ViewBag.Security != null)
                        {
                            foreach (SYS_CMS_SECURITY item in ViewBag.Security)
                            {
                                string thisvalue = ',' + obj.SecurityValue + ",";
                                string itemvalue = ',' + item.Value + ",";
                                if (obj.SecurityType == 2 && thisvalue.Contains(itemvalue))
                                {
                            <label class="f-label col col-6" style="white-space: normal; word-wrap: break-word">
                                <input type="checkbox" class="f-checkbox" checked="checked" value="@item.Value">@item.Name</label>
                                }
                                else
                                {
                            <label class="f-label col col-6" style="white-space: normal; word-wrap: break-word">
                                <input type="checkbox" class="f-checkbox"  value="@item.Value">@item.Name</label>
                                }
                            }
                        }
                    </div>
                </div>

            </div>

        </div>
    </div>
    <div class="box">
        <h3 class='box-h box-h-noborder'>用户IP设置 
        </h3>
        <div class="btn-group clearfix inline-block ml10" style="padding-top: 10px; padding-bottom: 10px">
            <a class="btn btn-white fl" href="javascript:void(0);" onclick="addIP()">添加</a>
            <a class="btn btn-white" style="margin-left: 10px" href="javascript:void(0);" onclick="deleteMult()">删除</a>
        </div>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="table table-grey" id="iptable">
            <thead class='th-wr'>
                <tr class="thead">
                    <th class="tdnum tdnum1">
                        <input class="ipall" type="checkbox" onclick="ipcheckall(this)">序号</th>
                    <th class='tc'>起始IP</th>
                    <th>终止IP</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @{
                    if (ViewBag.thisUserID == 0)//新增模式
                    {
                    <tr class='even'>
                        <td class="checkboxip">
                            <input type="checkbox" value="1">1</td>
                        <td>0.0.0.0</td>
                        <td>255.255.255.255</td>
                        <td class="tc">
                            <a href="javascript:void(0);" onclick="editIP(this)">编辑</a>
                            <a href="javascript:void(0);" onclick="deleteIP(this)">删除</a>
                        </td>
                    </tr>
                    }
                    else  //修改模式
                    {
                        if (ViewBag.UserGroupIp != null)
                        {
                            int sortno = 1;
                            foreach (SYS_CMS_USER_IP item in ViewBag.UserGroupIp)
                            {
                                string str = "even";
                                if (sortno % 2 == 0)
                                {
                                    str = "odd";
                                }
                    <tr class='@str'>
                        <td class="checkboxip">
                            <input type="checkbox" value="@sortno">@sortno</td>
                        <td>@item.SIP</td>
                        <td>@item.EIP</td>
                        <td class="tc">
                            <a href="javascript:void(0);" onclick="editIP(this)">编辑</a>
                            <a href="javascript:void(0);" onclick="deleteIP(this)">删除</a>
                        </td>
                    </tr>
                                sortno = sortno + 1;
                            }
                        }

                    }
                }

            </tbody>
        </table>

    </div>
    <div class="tc mt30" style="padding-bottom: 30px">

        <button class="btn btn-m btn-submit btn-warn-f" onclick="userSave()">完成设置</button>
        <button class="btn btn-m btn-prim-f" style="margin-left:20px" onclick="ajaxLoad('initload','@Html.Raw(Url.Action("UserIndex", "Admin_User"))')">返回</button>
    </div>
</div>


<div class="talkDivBg" style="display: none;">
    <!--talkDiv弹出层(不带图片，宽550)-->
    <div class="talkDiv talkW-550 form-h form-h-8em" style="display: none">
        <div class="talkDiv-title">
            <span>添加IP</span>
            <a class="icon icon-close" title="关闭" href="javascript:void(0);" onclick="closeIP()"><i class="iconfont icon-error3"></i></a>
        </div>
        <div class="talkDiv-body">

            <div class="f-gp">
                <div class="f-lb">
                    <label class="f-label">起始IP：</label>
                </div>
                <div class="f-ct">
                    <input type="text" class="f-text span4" id="startIP" maxlength="19"><span class="f-label-re">*</span>
                </div>
            </div>

            <div class="f-gp">
                <div class="f-lb">
                    <label class="f-label">终止IP：</label>
                </div>
                <div class="f-ct">
                    <input type="text" class="f-text span4" id="endIP" maxlength="19"><span class="f-label-re">*</span>
                </div>
            </div>

        </div>
        <div class="talkDiv-btn"><a href="javascript:void(0);" class="btn btn-m btn-prim-f btn-submit" onclick="saveIP()">保存</a> </div>
    </div>
</div>
